class Solution:
    def simplifyPath(self, path: str) -> str:
        # 优雅
        stk = []
        # 字符串切割
        for s in path.split('/'):
            if s == "" or s == ".":
                continue
            if s != "..":
                stk.append(s)
            elif stk:
                stk.pop()
        return '/' + '/'.join(stk)
